<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<div id="app">
    <prop-com></prop-com>
</div>
</body>

</html>

<!-- 组件结构 -->
<template id="prop">
    <fieldset>
        <legend>组件</legend>
        <h1>props:{{name}}</h1>
    </fieldset>
</template>
<script src='https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js'></script>
<script>

    //props数据验证是比较重要的,因为这样能保证数据类型是安全的

    let vm = new Vue({
        el: "#app",
        data: {
            msg: "校验"
        },
        components: {
            'prop-com': {
                template: "#prop",
                // 对props可以进行数据验证
                // props:['name']
                props: {
                    //接收的参数
                    name: {
                        //接受的类型
                        type: Number,
                        //必传参数
                        required: true,
                        //默认值
                        default() {
                            return 6666
                        }
                    },
                    age: {}
                }
            },
        }
    })
</script>